package org.example.microservice.sys.model.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 建表语句：
 * CREATE TABLE `sys_user` (
 *   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '操作员id',
 *   `username` varchar(128) NOT NULL COMMENT '登录帐号',
 *   `nickname` varchar(128) NOT NULL COMMENT '用户姓名',
 *   `password` varchar(128) NOT NULL COMMENT '密码',
 *   `status` smallint(6) NOT NULL DEFAULT '1' COMMENT '用户状态：1 正常；2 冻结',
 *   `department_id` varchar(60) DEFAULT NULL COMMENT '所属部门',
 *   `birthday` date DEFAULT NULL COMMENT '出生日期',
 *   `phone_number` varchar(128) DEFAULT NULL COMMENT '联系电话',
 *   `email` varchar(128) DEFAULT NULL COMMENT '电子邮件',
 *   `creator_user` bigint(20) DEFAULT NULL COMMENT '创建人',
 *   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
 *   PRIMARY KEY (`id`),
 *   UNIQUE KEY `username` (`username`),
 *   KEY `department_id` (`department_id`)
 * ) COMMENT='用户信息表';
 */
@Data
@TableName("sys_user")
@ApiModel(value = "用户信息")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("登录帐号")
    @TableField("username")
    private String username;

    @ApiModelProperty("用户姓名")
    @TableField("nickname")
    private String nickname;

    @ApiModelProperty("密码")
    @TableField("password")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @ApiModelProperty("用户状态：1 正常；2 冻结")
    @TableField("status")
    private Integer status;

    @ApiModelProperty("所属部门")
    @TableField("department_id")
    private String departmentId;

    @ApiModelProperty("出生日期")
    @TableField("birthday")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    @ApiModelProperty("联系电话")
    @TableField("phone_number")
    private String phoneNumber;

    @ApiModelProperty("电子邮件")
    @TableField("email")
    private String email;

    @ApiModelProperty("创建人")
    @TableField("create_user")
    private String createUser;

    @ApiModelProperty("创建时间")
    @TableField("create_time")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
}
